import pprint

x : str = "abcdefghe"
y : str = "aacdeeee"

def LSC(x, y):
    # 生成一个二位数组 
    # x 列
    # y 行
    m = len(x)
    n = len(y)
    # 这里必须加一因为， 有 i - 1, j - 1 的情况
    result_list = [[0 for j in range(n + 1)] for i in range(m + 1)]
    for i in range(1, len(x)+1):
        for j in range(1, len(y)+1):
            if x[i-1] == y[j-1]:
                result_list[i][j] = result_list[i-1][j-1] + 1
            elif x[i-1] != y[j-1]:
                result_list[i][j] = max( result_list[i-1][j], result_list[i][j-1] )      
    return result_list, result_list[m][n]

result_list, max_len = LSC(x, y)
pprint.pprint(result_list)


            
        
        

